<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>5.jsonp跨域</title>
</head>

<body>
    <script>
        //定义回调函数
        function show(data) {
            console.log(data)
        }
        //定义jsonp
        function jsonp(url) {

            var head = document.querySelector('head')
            var script = document.createElement('script')
            script.src = "http://localhost:3000?" + url
            head.appendChild(script)
        }
        //发送请求得到数据
        var url = "name=zbc&age=26&jsonp=show"
        jsonp(url, function (data) {
            console.log(data)
        })
    </script>
</body>

</html>